#include "KeeperMessage.h"
#include "KeeperServer.h"

using namespace keeper_server;

void usage(int argc, char** argv) {
  std::stringstream ss;
  ss << "Usage: \n";
  ss << "    " << argv[0] << " <server id> <IP address and port>";
  ss << std::endl;

  std::cout << ss.str();
  exit(0);
}

int main(int argc, char** argv) {
  if (argc < 4) {
    std::cout << "use like ./keeper_server id host:port leveledbname"
              << std::endl;
    return 0;
  }
  KeeperServer* server = new KeeperServer();
  server->set_server_info(argc, argv);


  std::cout << "    -- Echo Server with Raft --" << std::endl;
  std::cout << "               Version 0.1.0" << std::endl;
  std::cout << "    Server ID:    " << server->get_server_id() << std::endl;
  std::cout << "    Endpoint:     " << server->get_endpoint() << std::endl;
  server->init_raft();
  server->loop();
  return 0;
}
